package chapter4;

import apple.laf.JRSUIUtils;

import java.util.HashSet;
import java.util.HashMap;
import java.util.TreeMap;

public class HashMapTest {
    public static void main(String[] args) {
        TreeMap<Integer,String> treeMap1 = new TreeMap<>();
        treeMap1.put(7,"7");
        treeMap1.put(5,"5");
        treeMap1.put(4,"4");
        treeMap1.put(3,"3");
        treeMap1.put(9,"9");
        treeMap1.put(2,"2");
        System.out.println(treeMap1.containsKey(5));
        System.out.println(treeMap1.get(5));
        System.out.println(treeMap1.firstKey());//最小的key
        System.out.println(treeMap1.lastKey());//最大的key
        System.out.println(treeMap1.floorKey(8));//在表中所有<=8的数中，离8最近的
        System.out.println(treeMap1.ceilingKey(8));//在所有>=8中，离8最近
        treeMap1.remove(5);

    }
    public static void main1(String[] args) {
        HashSet<Integer> hashSet1 = new HashSet<>();
        hashSet1.add(3);
        System.out.println(hashSet1.contains(3));
        hashSet1.remove(3);
        System.out.println(hashSet1.contains(3));

        HashMap<Integer,String> mapTest = new HashMap<>();
        mapTest.put(1,"zuo");//增
        mapTest.put(1,"cheng");//改
        mapTest.put(2,"2");

        System.out.println(mapTest.containsKey(1));
        System.out.println(mapTest.get(1));//查
        System.out.println(mapTest.get(4));

        mapTest.remove(2);//删
    }
}
